home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Colourlist Example
- ** ------------------
- ** Colourlists are those nice colour gradients used in demos and games,
- ** usually sitting in the background of your screen. Colourlists are mostly
- ** good for getting more colours on screen than what is really available.
- ** Although GMS allows you to do other screen effects based on raster lines,
- ** we'll just stick to changing colours in this demo.
- **
- ** You can move the green colour bar by moving the mouse up and down.
- ** You will notice that if you move the green bar into the upper red bar,
- ** your bar will disappear and leave some green lines at the end of the red
- ** bar. This is because:
- **
- ** WAITLINE 95 ;Wait for line 95
- ** WAITLINE 100 ;Wait for line 100
- ** WAITLINE 90 ;Wait for line 90 <--Error!
- **
- ** Is illegal. The monitor beam travels down the screen, and so the
- ** UpdateRasterlist() routine will expect all lines to be in sequential order.
- ** Moving two colourbars into each other breaks this rule, causing the wait
- ** command to be ignored. If you want to get around this (green bar appears
- ** on top of red bar), you will have to have just one large colourlist and sort
- ** your colours before each call to UpdateRasterlist().
- **
- ** Similarly if you move the colour bar too far down the screen the hardware
- ** won't like it because lines > 311 don't exist. It's up to you to be
- ** responsible enough to stop this from happening!
- **
- ** Press the left mouse button to exit the demo.
- */
-
- #include <proto/games.h>
-
- extern struct GMSBase *GMSBase;
- ULONG _XCEXIT = NULL;
- APTR PREFSNAME = DEFAULT;
-
- LONG ColourBar1[] = {
- 0x100000,0x200000,0x300000,0x400000,0x500000,0x600000,0x700000,0x800000,0x900000,0xa00000,
- 0xb00000,0xc00000,0xd00000,0xe00000,0xe00000,0xe00000,0xd00000,0xc00000,0xb00000,0xa00000,
- 0x900000,0x800000,0x700000,0x600000,0x500000,0x400000,0x300000,0x200000,0x100000,0x000000,
- -1
- };
-
- LONG ColourBar2[] = {
- 0x001000,0x002000,0x003000,0x004000,0x005000,0x006000,0x007000,0x008000,0x009000,0x00a000,
- 0x00b000,0x00c000,0x00d000,0x00e000,0x00f000,0x00e000,0x00d000,0x00c000,0x00b000,0x00a000,
- 0x009000,0x008000,0x007000,0x006000,0x005000,0x004000,0x003000,0x002000,0x001000,0x000000,
- -1
- };
-
- LONG ColourBar3[] = {
- 0x000010,0x000020,0x000030,0x000040,0x000050,0x000060,0x000070,0x000080,0x000090,0x0000a0,
- 0x0000b0,0x0000c0,0x0000d0,0x0000e0,0x0000f0,0x0000e0,0x0000d0,0x0000c0,0x0000b0,0x0000a0,
- 0x000090,0x000080,0x000070,0x000060,0x000050,0x000040,0x000030,0x000020,0x000010,0x000000,
- -1
- };
-
- ULONG Rasterlist[] = {
- COLOURLIST(000,3,00,&ColourBar1), /* Line, Skip, Colnum, ColourList */
- COLOURLIST(160,1,00,&ColourBar2), /* Line, Skip, Colnum, ColourList */
- COLOURLIST(230,1,00,&ColourBar3), /* Line, Skip, Colnum, ColourList */
- RASTEND
- };
-
- void main(void)
- {
- struct GameScreen *GameScreen;
- WORD barpos = 160;
- ULONG mouse;
-
- if (GameScreen = AddScreenTags(TAGS_GAMESCREEN,NULL,
- GSA_Rasterlist,&Rasterlist,
- GSA_Planes,1,
- GSA_Attrib,BLKBDR,
- TAGEND)) {
-
- ShowScreen(GameScreen);
- InitJoyPorts();
-
- do {
- mouse = ReadJoyPort(JPORT1,JT_ZBXY);
- barpos += (BYTE)mouse;
- if (barpos < 0) barpos = 0;
- if (barpos > 226) barpos = 226;
- Rasterlist[4] = (Rasterlist[4] & 0xffff0000)|barpos;
- UpdateRasterLines(GameScreen);
- WaitVBL();
- } while (!(mouse & MB_LMB));
-
- DeleteScreen(GameScreen);
- }
- }
-
-